import { BasePlugin } from "./BasePlugin";
import * as http from "https";
import { endianness } from "os";
export class VideoM3U8Get extends BasePlugin {
    getName(): string {
        return "在线视频地址获取工具"
    }
    getDesc(): string {
        return "在线视频地址获取工具"
    }
    do(args: string[], cb: () => void): void {
        let urlList = [
            {fileName:"1.mp4", url:"https://www.smmy365.com/detail/play/32063-2-1.html"},
            {fileName:"2.mp4", url:"https://www.smmy365.com/detail/play/32063-2-2.html"},
            {fileName:"3.mp4", url:"https://www.smmy365.com/detail/play/32063-2-3.html"},
            {fileName:"4.mp4", url:"https://www.smmy365.com/detail/play/32063-2-4.html"},
            {fileName:"5.mp4", url:"https://www.smmy365.com/detail/play/32063-2-5.html"},
            {fileName:"6.mp4", url:"https://www.smmy365.com/detail/play/32063-2-6.html"},
            {fileName:"7.mp4", url:"https://www.smmy365.com/detail/play/32063-2-7.html"},
            {fileName:"8.mp4", url:"https://www.smmy365.com/detail/play/32063-2-8.html"},
            {fileName:"9.mp4", url:"https://www.smmy365.com/detail/play/32063-2-9.html"},
            {fileName:"10.mp4", url:"https://www.smmy365.com/detail/play/32063-2-10.html"},
            {fileName:"11.mp4", url:"https://www.smmy365.com/detail/play/32063-2-11.html"},
            {fileName:"12.mp4", url:"https://www.smmy365.com/detail/play/32063-2-12.html"},
            {fileName:"13.mp4", url:"https://www.smmy365.com/detail/play/32063-2-13.html"},
            {fileName:"14.mp4", url:"https://www.smmy365.com/detail/play/32063-2-14.html"},
            {fileName:"15.mp4", url:"https://www.smmy365.com/detail/play/32063-2-15.html"},
            {fileName:"16.mp4", url:"https://www.smmy365.com/detail/play/32063-2-16.html"},
            {fileName:"17.mp4", url:"https://www.smmy365.com/detail/play/32063-2-17.html"},
            {fileName:"18.mp4", url:"https://www.smmy365.com/detail/play/32063-2-18.html"},
            {fileName:"19.mp4", url:"https://www.smmy365.com/detail/play/32063-2-19.html"},
            {fileName:"20.mp4", url:"https://www.smmy365.com/detail/play/32063-2-20.html"},
            {fileName:"21.mp4", url:"https://www.smmy365.com/detail/play/32063-2-21.html"},
            {fileName:"22.mp4", url:"https://www.smmy365.com/detail/play/32063-2-22.html"},
            {fileName:"23.mp4", url:"https://www.smmy365.com/detail/play/32063-2-23.html"},
            {fileName:"24.mp4", url:"https://www.smmy365.com/detail/play/32063-2-24.html"},
            {fileName:"25.mp4", url:"https://www.smmy365.com/detail/play/32063-2-25.html"},
            {fileName:"26.mp4", url:"https://www.smmy365.com/detail/play/32063-2-26.html"},
            {fileName:"27.mp4", url:"https://www.smmy365.com/detail/play/32063-2-27.html"},
            {fileName:"28.mp4", url:"https://www.smmy365.com/detail/play/32063-2-28.html"},
            {fileName:"29.mp4", url:"https://www.smmy365.com/detail/play/32063-2-29.html"},
            {fileName:"30.mp4", url:"https://www.smmy365.com/detail/play/32063-2-30.html"},
            {fileName:"31.mp4", url:"https://www.smmy365.com/detail/play/32063-2-31.html"},
            {fileName:"32.mp4", url:"https://www.smmy365.com/detail/play/32063-2-32.html"},
            {fileName:"33.mp4", url:"https://www.smmy365.com/detail/play/32063-2-33.html"},
            {fileName:"34.mp4", url:"https://www.smmy365.com/detail/play/32063-2-34.html"},
            {fileName:"35.mp4", url:"https://www.smmy365.com/detail/play/32063-2-35.html"},
            {fileName:"36.mp4", url:"https://www.smmy365.com/detail/play/32063-2-36.html"},
            {fileName:"37.mp4", url:"https://www.smmy365.com/detail/play/32063-2-37.html"},
            {fileName:"38.mp4", url:"https://www.smmy365.com/detail/play/32063-2-38.html"},
            {fileName:"39.mp4", url:"https://www.smmy365.com/detail/play/32063-2-39.html"},
            {fileName:"40.mp4", url:"https://www.smmy365.com/detail/play/32063-2-40.html"},
            {fileName:"41.mp4", url:"https://www.smmy365.com/detail/play/32063-2-41.html"},
            {fileName:"42.mp4", url:"https://www.smmy365.com/detail/play/32063-2-42.html"},
            {fileName:"43.mp4", url:"https://www.smmy365.com/detail/play/32063-2-43.html"},
            {fileName:"44.mp4", url:"https://www.smmy365.com/detail/play/32063-2-44.html"},
            {fileName:"45.mp4", url:"https://www.smmy365.com/detail/play/32063-2-45.html"},
            {fileName:"46.mp4", url:"https://www.smmy365.com/detail/play/32063-2-46.html"},
            {fileName:"47.mp4", url:"https://www.smmy365.com/detail/play/32063-2-47.html"},
            {fileName:"48.mp4", url:"https://www.smmy365.com/detail/play/32063-2-48.html"},
            {fileName:"49.mp4", url:"https://www.smmy365.com/detail/play/32063-2-49.html"},
            {fileName:"50.mp4", url:"https://www.smmy365.com/detail/play/32063-2-50.html"},
            {fileName:"51.mp4", url:"https://www.smmy365.com/detail/play/32063-2-51.html"},
            {fileName:"52.mp4", url:"https://www.smmy365.com/detail/play/32063-2-52.html"},
            {fileName:"53.mp4", url:"https://www.smmy365.com/detail/play/32063-2-53.html"},
            {fileName:"54.mp4", url:"https://www.smmy365.com/detail/play/32063-2-54.html"},
            {fileName:"55.mp4", url:"https://www.smmy365.com/detail/play/32063-2-55.html"},
            {fileName:"56.mp4", url:"https://www.smmy365.com/detail/play/32063-2-56.html"},
            {fileName:"57.mp4", url:"https://www.smmy365.com/detail/play/32063-2-57.html"},
            {fileName:"58.mp4", url:"https://www.smmy365.com/detail/play/32063-2-58.html"},
            {fileName:"59.mp4", url:"https://www.smmy365.com/detail/play/32063-2-59.html"},
            {fileName:"60.mp4", url:"https://www.smmy365.com/detail/play/32063-2-60.html"},
            {fileName:"61.mp4", url:"https://www.smmy365.com/detail/play/32063-2-61.html"},
            {fileName:"62.mp4", url:"https://www.smmy365.com/detail/play/32063-2-62.html"},
            {fileName:"63.mp4", url:"https://www.smmy365.com/detail/play/32063-2-63.html"},
            {fileName:"64.mp4", url:"https://www.smmy365.com/detail/play/32063-2-64.html"},
            {fileName:"65.mp4", url:"https://www.smmy365.com/detail/play/32063-2-65.html"},
            {fileName:"66.mp4", url:"https://www.smmy365.com/detail/play/32063-2-66.html"},
            {fileName:"67.mp4", url:"https://www.smmy365.com/detail/play/32063-2-67.html"},
            {fileName:"68.mp4", url:"https://www.smmy365.com/detail/play/32063-2-68.html"},
            {fileName:"69.mp4", url:"https://www.smmy365.com/detail/play/32063-2-69.html"},
            {fileName:"70.mp4", url:"https://www.smmy365.com/detail/play/32063-2-70.html"},
            {fileName:"71.mp4", url:"https://www.smmy365.com/detail/play/32063-2-71.html"},
            {fileName:"72.mp4", url:"https://www.smmy365.com/detail/play/32063-2-72.html"},
            {fileName:"73.mp4", url:"https://www.smmy365.com/detail/play/32063-2-73.html"},
            {fileName:"74.mp4", url:"https://www.smmy365.com/detail/play/32063-2-74.html"},
            {fileName:"75.mp4", url:"https://www.smmy365.com/detail/play/32063-2-75.html"},
            {fileName:"76.mp4", url:"https://www.smmy365.com/detail/play/32063-2-76.html"},
        ];


        for (let index = 0; index < urlList.length; index++) {
            const urlObj = urlList[index];
            console.log(urlObj)

            var url = urlObj.url;
            // 参数url 和 回调函数
            http.get(url, function (res) {
                var html = '';
                // 绑定data事件 回调函数 累加html片段
                res.on('data', function (data) {
                html += data;
                });

                res.on('end', function () {
                // console.log(html);
                    let startIndex = html.indexOf("var zanpiancms_player") + 32;
                    let endIndex = html.indexOf("index.m3u8") + 10;
                    let urlm3u8 = html.substring(startIndex, endIndex);
                    console.log(urlm3u8, urlObj.fileName, index);
                });
            }).on('error', function () {
                console.log('获取数据错误');
            });
        }
    }

}